package org.liukai.ssh_ems.dao;

import org.hibernate.SessionFactory;
import org.liukai.ssh_ems.entity.po.User;
import org.springframework.orm.hibernate4.support.HibernateDaoSupport;
import org.springframework.stereotype.Repository;

import javax.annotation.Resource;
import java.util.List;

/**
 * @project ssh_ems
 * @create UserDao.java 
 * 
 * @author liukai
 * @date 2016/1/14 16:03
 * @detail 
 */

@Repository
public class UserDao extends HibernateDaoSupport {

    @Resource
    public void setSF(SessionFactory sessionFactory) {
        super.setSessionFactory(sessionFactory);
    }

    public User queryUserByusername(String username) {
        List<User> list = (List<User>) getHibernateTemplate().find("from User where username = ?", username);
        return list.size() != 0 ? list.get(0) : null;
    }
}
